#include<iostream>
#include<list>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	list<int> tableA;
	for (int i = 1; i <= n; i++)
	{
		tableA.push_back(i);
	}
	list<int>::iterator it = tableA.begin();
	while (tableA.size() > 1)
	{
		for (int i = 1;i < m;i++)
		{
			it++;
			if (it == tableA.end())
			{
				it = tableA.begin();
			}
		}
		cout << *it << ' ';
		list<int>::iterator next = ++it;
		if (next == tableA.end())
		{
			next = tableA.begin();
		}
		tableA.erase(--it);
		it = next;
	}
	cout << *it;
	return 0;

}